package com.example.demo.controller;

import com.example.demo.domain.SchoolMaxScore;
import com.example.demo.domain.SchoolScore;
import com.example.demo.result.JsonResult;
import com.example.demo.service.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("school")
public class SchoolController {
    @Resource
    private SchoolService schoolService;
    @GetMapping("getavgScore")
    public JsonResult<List<SchoolScore>> getAvgScore(){
        List<SchoolScore> schoolScores =  schoolService.getAvgScore();
        return JsonResult.ok(schoolScores);
    }


    @GetMapping("getMaxScore")
    public  JsonResult<List<SchoolMaxScore>> getMaxScore(){
        List<SchoolMaxScore> schoolMaxScores = schoolService.getMaxScore();
        return JsonResult.ok(schoolMaxScores);
    }
}
